import produce from "immer";

const initState = {
    size:localStorage.getItem("size") || "middle",
   // lang:'zh_CN'  在仓库中获取zh
   lang:localStorage.getItem("lang") || navigator.language.split("-")[0],
   
}


function reducer (state = initState, {type,payload}) {
    // console.log("收到信号：",action);
    return produce(state,(newState)=>{
        switch (type) {
            case"APP_SIZE_ADD":
            newState.size += payload
            localStorage.setItem("size",payload)
            break;
            case"APP_LANG":
            newState.lang = payload ;
            localStorage.setItem("lang",payload)          
            break;
        default:
        }
    })
}

export default reducer;